package controller;

import com.jfinal.aop.Inject;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import io.jboot.app.JbootApplication;
import model.User;
import service.UserService;
import io.jboot.web.controller.JbootController;
import io.jboot.web.controller.annotation.RequestMapping;

import java.util.Arrays;
import java.util.List;

/**
 * @author: 孙先生
 * @createTime: 2023/05/24 22:36
 * @description:
 */
@RequestMapping("/")
public class IndexController extends JbootController {

    @Inject
    private UserService userService;
    //public void page(Integer pageNum, Integer pageSize) {
    //    Page<Record> paginate = Db.paginate(pageNum, pageSize, new SqlPara().setSql("select * from user"));
    //    renderText(paginate.toString());
    //}
    public void index() {
        renderText("hello world");
    }

    public void dbtest(){
        List<Record> records = Db.find("select * from user");
        renderText(Arrays.toString(records.toArray()));
    }
    public void list(){
        List<User> all = userService.findAll();
        renderText(Arrays.toString(all.toArray()));
    }

    public static void main(String[] args) {
        JbootApplication.run(args);
    }
}
